}
}
+/**
+ * gdk_display_create_gl_context:
+ * @self: a `GdkDisplay`
+ * @error: return location for an error
+ *
+ * Creates a new `GdkGLContext` for the `GdkDisplay`.
+ *
+ * The context is disconnected from any particular surface or surface
+ * and cannot be used to draw to any surface. It can only be used to
+ * draw to non-surface framebuffers like textures.
+ *
+ * If the creation of the `GdkGLContext` failed, @error will be set.
+ * Before using the returned `GdkGLContext`, you will need to
+ * call [method@Gdk.GLContext.make_current] or [method@Gdk.GLContext.realize].
+ *
+ * Returns: (transfer full) (nullable): the newly created `GdkGLContext`
+ *
+ * Since: 4.6
+ */
+GdkGLContext *
+gdk_display_create_gl_context (GdkDisplay *self,
+ GError **error)
+{
+ g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ if (!gdk_display_prepare_gl (self, error))
+ return NULL;
+
+ return gdk_gl_context_new (self, NULL);
+}
+
/*< private >
* gdk_display_get_gl_context:
* @self: the `GdkDisplay`
GDK_AVAILABLE_IN_4_4
gboolean gdk_display_prepare_gl (GdkDisplay *self,
GError **error);
+GDK_AVAILABLE_IN_4_6
+GdkGLContext *gdk_display_create_gl_context(GdkDisplay *self,
+ GError **error);
GDK_AVAILABLE_IN_ALL
GdkDisplay *gdk_display_get_default (void);
/* Must have called gdk_display_prepare_gl() before */
GdkGLContext *
-gdk_gl_context_new_for_surface (GdkSurface *surface)
+gdk_gl_context_new (GdkDisplay *display,
+ GdkSurface *surface)
{
- GdkDisplay *display = gdk_surface_get_display (surface);
- GdkGLContext *shared = gdk_display_get_gl_context (display);
+ GdkGLContext *shared;
+
+ g_assert (surface == NULL || display == gdk_surface_get_display (surface));
/* assert gdk_display_prepare_gl() had been called */
+ shared = gdk_display_get_gl_context (display);
g_assert (shared);
return g_object_new (G_OBJECT_TYPE (shared),
+ "display", display,
"surface", surface,
NULL);
}
GError **error);
void gdk_gl_backend_use (GdkGLBackend backend_type);
-GdkGLContext * gdk_gl_context_new_for_surface (GdkSurface *surface);
+GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
+ GdkSurface *surface);
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
GdkGLAPI api,
if (!gdk_display_prepare_gl (surface->display, error))
return NULL;
- return gdk_gl_context_new_for_surface (surface);
+ return gdk_gl_context_new (surface->display, surface);
}
/**